package com.siecomzg.transport;

import com.siecomzg.constconfig.ConstDefine;
import com.siecomzg.transport.handler.FinanHandler;
import com.siecomzg.transport.handler.FingerPrintHandler;
import com.siecomzg.transport.handler.IdentityHandler;
import com.siecomzg.transport.handler.KeyBoardHandler;
import com.siecomzg.transport.handler.OtherHandler;
import com.siecomzg.transport.handler.ServiceHandler;
import com.siecomzg.transport.handler.SignatureHandler;
import com.siecomzg.transport.handler.UpdateHandler;

import java.util.HashMap;

/**
 * Created  on 2016/7/26.
 */
public class HandlerManger {



    private static HashMap<Integer, ServiceHandler> handlerMap = new HashMap<Integer, ServiceHandler>();

    private static HandlerManger ourInstance = new HandlerManger();

    public static HandlerManger getInstance() {
        return ourInstance;
    }

    static {
        addHandler(ConstDefine.ID_MODULE, new IdentityHandler());
        addHandler(ConstDefine.FINAN_MODULE, new FinanHandler());
        addHandler(ConstDefine.FINGE_MODULE, new FingerPrintHandler());
        addHandler(ConstDefine.KEY_MODULE,new KeyBoardHandler());
//        addHandler(ConstDefine.HEARTBEAT_MODULE,new HeartbeatHandler());
        addHandler(ConstDefine.OTHER_MODULE,new OtherHandler());
        addHandler(ConstDefine.SIGNATURE_MODULE,new SignatureHandler());
        addHandler(ConstDefine.UPDATE_MODULE,new UpdateHandler());
    }

    public static HashMap<Integer, ServiceHandler> getHandlerMap() {
        return handlerMap;
    }


    public static void addHandler(int module, ServiceHandler handler) {

        handlerMap.put(module, handler);

    }

    public static ServiceHandler getHandler(int module){

        return handlerMap.get(module);
    }


    public static void removeHandler(int module) {

        handlerMap.remove(module);
    }

}
